' 2-D Sales Table
' This program tracks the sales of soda over a given number of months
'   with a two-dimensional array.

CLS

PRINT "** Soda Sales Tracking Program **"
PRINT
WHILE (brands% < 1)
    INPUT "How many brands of soda do you sell?  ", brands%
WEND

WHILE (months% < 1) OR (months% > 12)
    INPUT "How many months would you like to record (1-12)?  ", months%
WEND
PRINT

OPTION BASE 1                                ' set first array element at 1
DIM sodaSales%(brands%, months%)  ' dimension soda sales array
DIM brandNames$(brands%)               ' dimension brand names array

' Get names of soda brands sold.

PRINT "Enter the"; brands%; "brands of soda you sell."
PRINT
FOR i% = 1 TO brands%
    INPUT "Brand name:  ", brandNames$(i%)
NEXT i%

' Get soda sales for each month.

PRINT
PRINT "Enter soda sales in cases."
PRINT

FOR i% = 1 TO brands%         ' for each brand of sodaI
    PRINT "** "; brandNames$(i%); " **"
    PRINT                              '   print name of brand
    FOR j% = 1 TO months%    ' for each monthI
        READ mo$                     '   read month name from DATA list
        PRINT "  "; mo$;            '   print month name and prompt for input
        INPUT ":  ", sodaSales%(i%, j%)  ' store input in array
    NEXT j%
    PRINT
    RESTORE                         ' rewind DATA list to first month
NEXT i%

' Print out soda sales table.

CLS

PRINT "Soda sales in cases for"; months%; "months:"
PRINT

TEXTFONT 4

PRINT "--------------------------------------------------------------"
PRINT "Brand/Month   ";

FOR i% = 1 TO months%
    PRINT " ";
    READ mo$                  ' read month name from DATA list
    PRINT mo$;                ' print month names across top of table
NEXT i%

PRINT
PRINT "--------------------------------------------------------------"

' Initialize templates for PRINT USING.
nameTmp$ = "\            \"    ' for brand name (up to 12 characters)
salesTmp$ = " ###"            ' for cases sold (up to 3 digits)

FOR i% = 1 TO brands%         ' fills in the table
    PRINT USING nameTmp$; brandNames$(i%);
    FOR j% = 1 TO months%
        PRINT USING salesTmp$; sodaSales%(i%, j%);
    NEXT j%
    PRINT
NEXT i%

PRINT "--------------------------------------------------------------"

TEXTFONT 1

PRINT
INPUT "Press Return to continue", dummy$

DATA Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec
